//
//  VisitorView.swift
//  WBSwift
//
//  Created by 贺瑞 on 2017/6/24.
//  Copyright © 2017年 herui. All rights reserved.
//

import UIKit


class VisitorView: UIView {
    
    @IBOutlet weak var turntableIV : UIImageView?
    
    var loginBlock : (()->())?
    var registerBlock : (()->())?

    class func visitorView() -> VisitorView {
        return Bundle.main.loadNibNamed("VisitorView", owner: nil, options: nil)?.first as! VisitorView;
    }
    
    
    override func awakeFromNib() {
        super.awakeFromNib()
        commonInit();
    }
    

    private func commonInit() {
        
        let anim = CABasicAnimation(keyPath: "transform.rotation.z")
        anim.fromValue = 0
        anim.toValue = Double.pi / 2
        anim.duration = 5
        anim.autoreverses = true
        anim.fillMode = kCAFillModeForwards
        anim.repeatCount = MAXFLOAT
        turntableIV?.layer.add(anim, forKey: nil)
        
    }
    
    @IBAction func loginBtnOnclick(_ sender: UIButton) {
        if let loginBlock = loginBlock {
            loginBlock()
        }
    }

    @IBAction func registerBtnOnclick(_ sender: UIButton) {
        if let registerBlock = registerBlock {
            registerBlock()
        }
    }
    
}
